|
OpenStack Newton : How to use Heat
2016/10/27 |
|
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
|
+------------------+ | +------------------------+
| [ Control Node ] | | | [ Network Node ] |
| Keystone |10.0.0.30 | 10.0.0.50| DHCP,L3,L2 Agent |
| Glance |------------+------------| Metadata Agent |
| Nova API |eth0 | eth0| Heat API,API-CFN |
| Neutron Server | | | Heat Engine |
+------------------+ | +------------------------+
eth0|10.0.0.51
+--------------------+
| [ Compute Node ] |
| Nova Compute |
| L2 Agent |
+--------------------+
|
| [1] | Deploy Instances with Heat services and templates. The example below is on the Controle Node. |
heat_template_version: 2016-10-14
description: Heat Sample Template
parameters:
ImageID:
type: string
description: Image used to boot a server
NetID:
type: string
description: Network ID for the server
resources:
server1:
type: OS::Nova::Server
properties:
name: "Heat_Deployed_Server"
image: { get_param: ImageID }
flavor: "m1.small"
networks:
- network: { get_param: NetID }
outputs:
server1_private_ip:
description: IP address of the server in the private network
value: { get_attr: [ server1, first_address ] }
[root@dlp ~(keystone)]#
openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 0f695de0-2bf6-4a51-93ea-0c87ac6a3d07 | CentOS7 | active | +--------------------------------------+---------+--------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 57841132-2c12-4a8b-b29f-2249eba54471 | ext_net | ea9dfc41-16e9-4f6b-8cd0-6024c3299488 | | cb956039-19e4-49d2-b2d3-6a1327c7b691 | int_net | 303fbd3b-eb58-48e7-9508-f74a55e0f3be | +--------------------------------------+---------+--------------------------------------+[root@dlp ~(keystone)]# Int_Net_ID=$(openstack network list | grep int_net | awk '{ print $2 }')
# create an instance from the template [root@dlp ~(keystone)]# openstack stack create -t sample-stack.yml --parameter "ImageID=CentOS7;NetID=$Int_Net_ID" Sample-Stack +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | id | 49378d71-0664-4eb1-8536-fa7f0a2adeab | | stack_name | Sample-Stack | | description | Heat Sample Template | | creation_time | 2016-10-28T01:47:39Z | | updated_time | None | | stack_status | CREATE_IN_PROGRESS | | stack_status_reason | Stack CREATE started | +---------------------+--------------------------------------+ # turn to "CREATE_COMPLETE" after few minutes later like follows [root@dlp ~(keystone)]# openstack stack list +--------------------------------------+--------------+-----------------+----------------------+--------------+ | ID | Stack Name | Stack Status | Creation Time | Updated Time | +--------------------------------------+--------------+-----------------+----------------------+--------------+ | 49378d71-0664-4eb1-8536-fa7f0a2adeab | Sample-Stack | CREATE_COMPLETE | 2016-10-28T01:47:39Z | None | +--------------------------------------+--------------+-----------------+----------------------+--------------+ # the instance is running which is created from the Heat template [root@dlp ~(keystone)]# openstack server list +-----------+----------------------+---------+------------------------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------------------+---------+------------------------------------+------------+ | 46a421d9- | Heat_Deployed_Server | ACTIVE | int_net=192.168.100.10 | CentOS7 | | e5a31503- | CentOS_7 | SHUTOFF | int_net=192.168.100.11, 10.0.0.200 | CentOS7 | +-----------+----------------------+---------+------------------------------------+------------+ # delete the instance likwe follows if you don't need [root@dlp ~(keystone)]# openstack stack delete --yes Sample-Stack
[root@dlp ~(keystone)]#
openstack stack list |
| [2] |
The guide for writing templates are opened on the official site below.
⇒ http://docs.openstack.org/developer/heat/template_guide/index.html |